Home:ALL Converter>Overriding a shared library in Linux with LD_PRELOAD

Overriding a shared library in Linux with LD_PRELOAD

Ask Time:2021-05-14T20:17:40         Author:Xophmeister

Json Formatter

I'm trying to fix a binary that seems to be dynamically linked to an older version of GSL (the GNU Scientific Library):

$ ldd my-binary
        ...
        libgsl.so.23 => /usr/lib/x86_64-linux-gnu/libgsl.so.23 (0x00007fc600d51000)
        ...

If I use LD_PRELOAD to set a newer version, my understanding was that the older version would be replaced. Instead, I'm just seeing two instances of the same library:

$ LD_PRELOAD=/path/to/my/libgsl.so.25.0.0 ldd my-binary
        ...
        /path/to/my/libgsl.so.25.0.0 (0xsomething)
        ...
        libgsl.so.23 => /usr/lib/x86_64-linux-gnu/libgsl.so.23 (0x00007fc600d51000)
        ...

Is that going to work, or will having them both in there cause problems?

Author:Xophmeister,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/67534232/overriding-a-shared-library-in-linux-with-ld-preload
yy